<?php
/**
 * 工程联系控制器
 */
class DocumentAction extends MessageAction {
	/*添加公文流程*/
	public function addDocument(){
		$data=$_POST;
		/*流程数据*/
		$process["process_num"]=time();
		$process['process_title']="公文流程单";
		$process['process_begin_id']=$data['document_author'];
		$process['process_now_id']=$data['document_proofreader'];
		$process['process_time']=$process["process_num"];
		$process['process_state']=$data['document_tag'];
		$process['process_type']='Document';
		$process['process_now_id_if_approval']=0;
		$process['process_parent_id']=0;
		$m=M("process");
		$id=$m->add($process);
		dump($id);
		if(false==$id){
			echo 0;
			exit;
		}else{
			$data['document_process_id']=$id;
			$m=M("document");
			$id1=$m->add($data);
			if(false==$id1){
				echo 0;
				exit;
			}else{
				$msg_from_name=$this->getOneEmployeName($data['document_author']);
                $msg_content=$msg_from_name.'向您提交了一条集团公文签批单，请注意查收';
                if($data['msg_tip']){
                    //发送消息
                    $msg_title="集团公文签批单";
                    $this->sendMsg($data['document_proofreader'],$data['document_author'],$msg_title,$msg_content);
                }

                if($data['msg_phone']){
                    //发送短信
                    $mobile=I('phone_num');
                    $content=$msg_content."【来自丽丰OA系统】";
                    $mobileids=$mobile.strval(time());
                    $this->sendSMS($mobile,$content,$mobileids);
                }

				echo 1;
				exit;
			}
		}
	}
}